var http = require("http");
var url = require("url");

function start(route, handle) {

  function onRequest(request, response) {
	  console.log("hellonodejs/server.js: Request received.");
		
	  var pathname = url.parse(request.url).pathname;
	  console.log("hellonodejs/server.js: Request for " + pathname + " received.");
		
	  route(handle, pathname, response, request);
 	}

  http.createServer(onRequest).listen(8888);
  console.log("hellonodejs/server.js: Server has started.");
}

exports.start = start;;